package com.wyx.producer.demo;

import com.wyx.pojo.Pic;
import com.wyx.pojo.constant.ConfigRead;
import com.wyx.service.PicService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.io.File;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @author 吴宇~
 * @motto 我亦无他，唯手熟尔。
 * @edition jdk1.8
 * @reflection 0-1 喧闹任其喧闹，自由我自为之，我自风情万种，与世无争。
 * @date 2024/08/04/10:25
 * @target 心若有所向往，何惧道阻且长
 */
@SpringBootTest
public class test1 {
    @Autowired
    private ConfigRead configRead;
    @Autowired
    private PicService picService;

    @Test
    public void test1() {
        File file = new File("src\\main\\resources\\smokePic");
        String[] list = file.list();
        for (String s : list) {
            System.out.println(s);
        }
    }

    @Test
    public void test2() {
        List<Pic> list = picService.list();
        Map<String, Pic> collect = list.stream().collect(Collectors.toMap(Pic::getPicAddress, pic -> pic));
        File file = new File("C:\\Users\\Administrator\\Desktop\\smokePic");
        String[] list1 = file.list();
        for (String s : list1) {
            String[] split = s.split("\\.");
            String name = split[0];
            if (collect.get(name) == null) {
                System.out.println(name);
            }
        }
    }

    @Test
    public void test3(){
        System.out.println(configRead.toString());
    }
}
